package com.ruoyi.appointmentSet.controller;

import java.util.List;

import com.ruoyi.common.utils.SecurityUtils;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.constant.DicConstants;
import com.ruoyi.appointmentSet.domain.AppointmentSet;
import com.ruoyi.appointmentSet.service.IAppointmentSetService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 预约设置Controller
 *
 * @author ch
 * @date 2022-07-26
 */
@RestController
@RequestMapping("/appointmentSet/appointmentSet")
public class AppointmentSetController extends BaseController
{
    @Autowired
    private IAppointmentSetService appointmentSetService;

    /**
     * 查询预约设置列表
     */
    @PreAuthorize("@ss.hasPermi('appointmentSet:appointmentSet:list')")
    @GetMapping("/list")
    public TableDataInfo list(AppointmentSet appointmentSet)
    {
        startPage();
        List<AppointmentSet> list = appointmentSetService.selectAppointmentSetList(appointmentSet);
        return getDataTable(list);
    }

    /**
     * 导出预约设置列表
     */
    @PreAuthorize("@ss.hasPermi('appointmentSet:appointmentSet:export')")
    @Log(title = "预约设置", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(AppointmentSet appointmentSet)
    {
        List<AppointmentSet> list = appointmentSetService.selectAppointmentSetList(appointmentSet);
        ExcelUtil<AppointmentSet> util = new ExcelUtil<AppointmentSet>(AppointmentSet.class);
        return util.exportExcel(list, "预约设置数据");
    }

    /**
     * 获取预约设置详细信息
     */
    @PreAuthorize("@ss.hasPermi('appointmentSet:appointmentSet:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(appointmentSetService.selectAppointmentSetById(id));
    }

    /**
     * 新增预约设置
     */
    @PreAuthorize("@ss.hasPermi('appointmentSet:appointmentSet:add')")
    @Log(title = "预约设置", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody AppointmentSet appointmentSet)
    {
        return toAjax(appointmentSetService.insertAppointmentSet(appointmentSet));
    }

    /**
     * 修改预约设置
     */
    @PreAuthorize("@ss.hasPermi('appointmentSet:appointmentSet:edit')")
    @Log(title = "预约设置", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody AppointmentSet appointmentSet)
    {
        appointmentSet.setUpdateType(DicConstants.BUSINESS_Manager.getCode());
        return toAjax(appointmentSetService.updateAppointmentSet(appointmentSet));
    }

    /**
     * 删除预约设置
     */
    @PreAuthorize("@ss.hasPermi('appointmentSet:appointmentSet:remove')")
    @Log(title = "预约设置", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(appointmentSetService.logicDeleteAppointmentSet(ids,DicConstants.BUSINESS_Manager.getCode(),SecurityUtils.getUserId()));
    }
}
